﻿#ifndef __MCLINEARDIMENSION2D_H_
#define __MCLINEARDIMENSION2D_H_

#include <MCDimension2D.h>
#include <MCPoint2D.h>
#include <MCLineSegment2D.h>

enum MCLinearDimensionAlligment
{
    DefaultAlligment,
    XAlligment,
    YAlligment
};

class MCLinearDimension2D : public MCDimension2D
{
public:

    MCLinearDimension2D();
    MCLinearDimension2D(const MCPoint2D &p1, const MCPoint2D &p2);

    MCDimensionType dimensionType() override;
    double length() override;

    double height() const;
    void setAlligment(MCLinearDimensionAlligment alligment);
    void setHeight(double height);
    void moveDimensionLine(const MCVector2 &to);

    // Много побочных методов, нужно пофиксить.
    MCLinearDimensionAlligment alligment() const;
    MCLineSegment2D dimensionLineNoTransform() const;
    MCLineSegment2D dimensionLine() const;
    MCLineSegment2D inversedDimensionLine() const; // need to fix
    MCLineSegment2D sourceLine() const;

    void update(const MCPoint2D &p1, const MCPoint2D &p2);

protected:

    MCLineSegment2D getAllignedLine(MCLinearDimensionAlligment alligment) const;
    MCLineSegment2D defaultAlligmentLine(const MCLineSegment2D &seg) const;
    MCLineSegment2D XAlligmentLine(const MCLineSegment2D &seg) const;
    MCLineSegment2D YAlligmentLine(const MCLineSegment2D &seg) const;

private:

    MCLineSegment2D _sourceLine;
    MCLinearDimensionAlligment _alligment;
    double _height;

};

#endif // !__MCLINEARDIMENSION2D_H_

